package com.eshop.order.controller;

import com.eshop.base.model.Order;
import com.eshop.base.protocol.Result;
import com.eshop.base.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单主表 前端控制器
 * </p>
 *
 * @author Your Name
 * @since 2025-05-11
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IOrderService orderService;

    @RequestMapping("/{id}")
    public Result<Order> create(@PathVariable("id") String orderNo) {
        Result<Order> result = new Result<>();
        try {
            Order order = orderService.create(orderNo);
            result = Result.success(order);
        } catch (Exception e) {
            log.info(e.getMessage());
            result = Result.failure();
        }
        return result;
    }
}
